<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>git常用命令 | 苟有恒 何必三更起五更眠 最无益 莫过一日曝十日寒</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="git 常规操作 初始化项目推送到github  123456vi .gitignoregit initgit add .git commit -m &quot;初始化&quot;git remote add origin git@github.com:buyaojingde&#x2F;unityframe.gitgit push -u origin master -f  带submodule的工程需要下载submodule使">
<meta property="og:type" content="article">
<meta property="og:title" content="git常用命令">
<meta property="og:url" content="http://dontworryneedmoney.gitee.io/guolianbo/2019/06/28/dontworry/%E6%9D%82%E9%A1%B9/git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/index.html">
<meta property="og:site_name" content="苟有恒 何必三更起五更眠 最无益 莫过一日曝十日寒">
<meta property="og:description" content="git 常规操作 初始化项目推送到github  123456vi .gitignoregit initgit add .git commit -m &quot;初始化&quot;git remote add origin git@github.com:buyaojingde&#x2F;unityframe.gitgit push -u origin master -f  带submodule的工程需要下载submodule使">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2019-06-27T17:26:12.000Z">
<meta property="article:modified_time" content="2020-06-08T12:50:52.888Z">
<meta property="article:author" content="worry dont">
<meta property="article:tag" content="杂项">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/guolianbo/atom.xml" title="苟有恒 何必三更起五更眠 最无益 莫过一日曝十日寒" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/guolianbo/css/style.css">

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/guolianbo/" id="logo">苟有恒 何必三更起五更眠 最无益 莫过一日曝十日寒</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/guolianbo/">Home</a>
        
          <a class="main-nav-link" href="/guolianbo/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/guolianbo/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://dontworryneedmoney.gitee.io/guolianbo"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="ejs-dontworry/杂项/git常用命令" class="article article-type-ejs" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/guolianbo/2019/06/28/dontworry/%E6%9D%82%E9%A1%B9/git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" class="article-date">
  <time datetime="2019-06-27T17:26:12.000Z" itemprop="datePublished">2019-06-28</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      git常用命令
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="git-常规操作"><a href="#git-常规操作" class="headerlink" title="git 常规操作"></a>git 常规操作</h2><ul>
<li>初始化项目推送到github</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">vi .gitignore</span><br><span class="line">git init</span><br><span class="line">git add .</span><br><span class="line">git commit -m <span class="string">"初始化"</span></span><br><span class="line">git remote add origin git@github.com:buyaojingde/unityframe.git</span><br><span class="line">git push -u origin master -f</span><br></pre></td></tr></table></figure>
<ul>
<li>带submodule的工程需要下载submodule使用命令<br><code>git submodule update --init --recursive</code></li>
</ul>
<ul>
<li><p><code>git branch -vv</code>查看链接</p>
</li>
<li><p><code>git branch --set-upstream-to=origin/hotfix/lianbo</code> 建立链接</p>
</li>
<li><p><code>git branch -r</code> 查看远程分支</p>
</li>
<li><p><code>git push origin hotfix/lianbo:hotfix/lianbo</code> 推送本地分支到远程</p>
</li>
<li><p><code>git push --set-upstream origin feature/wallquickdrag</code> 推送本地分支到远程</p>
</li>
<li><p><code>git push origin -D *BranchName*</code> 删除远程分支</p>
</li>
<li><p><code>git merge --no-ff mater</code> 合并master</p>
</li>
<li><p><code>git reflog --date=local | grep feature/cornerMerge@lianbo</code> 查看当前分支是从哪个分支分出来的</p>
</li>
<li><p><code>git push origin --delete _BranchName_</code>  删除本地分支</p>
</li>
<li><p><code>git checkout -b develop origni/develop</code> 检出远程分支到本地</p>
</li>
<li><p><code>git stash save &quot;&quot;</code>储存</p>
</li>
<li><p><code>git stash apply stash@{0}</code> // 取出储存的第一条</p>
</li>
<li><p><code>git push -u origin dev -f</code> // 强制推送本地仓库到远端,用来回滚版本</p>
</li>
<li><p><code>git reset --hard</code> 75c26377 回滚到一个版本</p>
</li>
<li><p>git 单个文件回滚到某个版本<br> <code>git log WallHide.ts</code><br>  <code>git checkout 6530c1358d1a0b66e9f5cf6106873431ddcec6c9 WallHide.ts</code></p>
</li>
<li><p>查看配置项 <code>git config  [--local|--global|--system] -l</code></p>
</li>
<li><p>删除配置项 <code>git config  [--local|--global|--system] unset http.proxy</code></p>
</li>
<li><p>git 删除某个文件的提交记录</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git filter-branch --force --index-filter <span class="string">'git rm --cached --ignore-unmatch FILE_PATH'</span> --prune-empty --tag-name-filter cat -- --all</span><br></pre></td></tr></table></figure>

<h2 id="git错误处理"><a href="#git错误处理" class="headerlink" title="git错误处理"></a><strong>git错误处理</strong></h2><ul>
<li><p>Git操作的过程中突然显示<code>Another git process semms to be running in this repository, e.g. an editor opened by ‘git commit’. Please make sure all processes are terminated then try again. If it still fails, a git process remove the file manually to continue…</code></p>
<p> <code>rm -f .git/index.lock // 删除index.lock文件</code></p>
<ul>
<li>git pull、git push 报错 fatal: Authentication failed for解决<blockquote>
<p>cmd（管理员）<code>git config --system --unset credential.helper</code>，清楚用户名和密码</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<blockquote>
<p>保存账号和密码<code>git config --global credential.helper store</code> ,是存储的意思，全局存储密码</p>
</blockquote>
<blockquote>
<p><code>cat ~/.git-credentials</code>，查看全局存储的账号密码</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">git push origin master --force</span><br><span class="line">rm -rf .git/refs/original/</span><br><span class="line">git reflog expire --expire=now --all</span><br><span class="line">git gc --prune=now</span><br><span class="line">git gc --aggressive --prune=now</span><br></pre></td></tr></table></figure>
<ul>
<li><p>commit 提交检查eslint时，可以用<code>git commit -m &quot;message info&quot; --no-verify</code>进行提交</p>
</li>
<li><p><code>.gitignore</code>不生效，使用<code>git rm -r --cached .</code>清除缓存</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git rm -r --cached .</span><br><span class="line">git add .</span><br><span class="line">git commit -m <span class="string">'update .gitignore'</span></span><br></pre></td></tr></table></figure>


<ul>
<li>Chrome 护眼命令</li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">document</span>.getElementsByTagName(<span class="string">'body'</span>)[<span class="number">0</span>].style.background=<span class="string">'#cce8cc'</span>;x=<span class="built_in">document</span>.getElementsByTagName(<span class="string">'div'</span>);<span class="keyword">for</span>(<span class="keyword">var</span> i=<span class="number">0</span>;i&lt;x.length;i++)&#123;x[i].style.background=<span class="string">'#cce8cc'</span>&#125;</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://dontworryneedmoney.gitee.io/guolianbo/2019/06/28/dontworry/%E6%9D%82%E9%A1%B9/git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" data-id="ckb6hw6ru001njcn2hk8k7ad8" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/guolianbo/tags/%E6%9D%82%E9%A1%B9/" rel="tag">杂项</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/guolianbo/2019/06/28/dontworry/Algorithm/%E7%9F%A9%E9%98%B5TRS%E8%BD%AC%E6%8D%A2/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          矩阵TRS转换
        
      </div>
    </a>
  
  
    <a href="/guolianbo/2019/06/23/dontworry/xiaofang/%E5%BB%BA%E7%AD%91%E9%98%B2%E7%81%AB/%E9%98%B2%E7%81%AB%E9%98%B2%E7%83%9F%E5%88%86%E5%8C%BA%E4%B8%8E%E5%88%86%E9%9A%94/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">防火防烟分区与分隔</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/guolianbo/categories/%E9%9A%8F%E7%AC%94/">随笔</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/Algorithm/" rel="tag">Algorithm</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/Unity3d/" rel="tag">Unity3d</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/%E6%9D%82%E9%A1%B9/" rel="tag">杂项</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/%E6%B6%88%E9%98%B2/" rel="tag">消防</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/%E7%94%B3%E8%AE%BA/" rel="tag">申论</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/%E9%9A%8F%E7%AC%94/" rel="tag">随笔</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/guolianbo/tags/Algorithm/" style="font-size: 14px;">Algorithm</a> <a href="/guolianbo/tags/Unity3d/" style="font-size: 12px;">Unity3d</a> <a href="/guolianbo/tags/%E6%9D%82%E9%A1%B9/" style="font-size: 18px;">杂项</a> <a href="/guolianbo/tags/%E6%B6%88%E9%98%B2/" style="font-size: 16px;">消防</a> <a href="/guolianbo/tags/%E7%94%B3%E8%AE%BA/" style="font-size: 10px;">申论</a> <a href="/guolianbo/tags/%E9%9A%8F%E7%AC%94/" style="font-size: 20px;">随笔</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/06/">June 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/05/">May 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/04/">April 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/03/">March 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/02/">February 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/01/">January 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/11/">November 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/09/">September 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/08/">August 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/07/">July 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/06/">June 2019</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/guolianbo/2020/06/08/dontworry/Unity3d/IObserver%E5%92%8CIObservable%E5%92%8CIDisposable/">IObserver和IObservable和IDisposable</a>
          </li>
        
          <li>
            <a href="/guolianbo/2020/05/28/dontworry/%E6%9D%82%E9%A1%B9/javascript%E7%9A%84%E6%9C%AC%E8%B4%A8/">javascript的本质</a>
          </li>
        
          <li>
            <a href="/guolianbo/2020/05/27/dontworry/%E6%9D%82%E9%A1%B9/%E5%8D%8F%E7%A8%8B%E7%9A%84%E5%8E%9F%E7%90%86/">协程的原理</a>
          </li>
        
          <li>
            <a href="/guolianbo/2020/05/20/dontworry/%E6%9D%82%E9%A1%B9/linux%E4%B8%8B%E7%9A%84nginx%E7%9A%84%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/">linux下的nginx的基本操作</a>
          </li>
        
          <li>
            <a href="/guolianbo/2020/05/15/dontworry/%E6%9D%82%E9%A1%B9/%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0%E5%8A%A8%E8%AF%8D/">常用函数动词</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 worry dont<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/guolianbo/" class="mobile-nav-link">Home</a>
  
    <a href="/guolianbo/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/guolianbo/fancybox/jquery.fancybox.css">

  
<script src="/guolianbo/fancybox/jquery.fancybox.pack.js"></script>




<script src="/guolianbo/js/script.js"></script>




  </div>
</body>
</html>